<route lang="json5" type="page">
  {
    style: {
      navigationBarTitleText: '成绩查询',
    },
    anonymous: false
  }
</route>

<script lang="ts" setup>
import ScoreItem from './components/ScoreItem.vue'
import { useUserStore } from '@/stores'
import { getScoreList } from '@/apis/score'

const userStore = useUserStore()
const scoreList = ref([])

const getList = async () => {
  const res = await getScoreList(userStore.currentStudent.id)
  scoreList.value = res || []
}

onLoad(() => {
  getList()
})

const onCardClick = (id) => {
  console.log('id = ', id)
  uni.navigateTo({ url: `/pages/exam/ExamDetail?id=${id}` })
}
</script>

<template>
  <view class="p-[30rpx]">
    <view v-for="(item, index) in scoreList" :key="item" class="mt-[24rpx]" :style="index === 0 ? 'margin-top:0' : ''">
      <ScoreItem :data="item" @tap="onCardClick(item.examRecordId)" />
    </view>
    <view v-if="!scoreList.length">
      <wd-status-tip image="content" tip="暂无数据" />
    </view>
  </view>
</template>

<style lang="scss" scoped>

</style>
